package com.hanamaki.struct;

import java.util.Scanner;

public class ForDemo03 {
    //循环录入某学员S1的5门课成绩，计算平均分

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入班级人数：");
        int personCount = scanner.nextInt();
        /*定义汇总的变量*/
        double score_sum = 0;

        for (int i = 1; i <= personCount; i++) {
            System.out.println("请输入班级中第" + i + "个人的成绩：");
            double score = scanner.nextDouble();
            score_sum += score;
        }


        /*计算平均分*/
        System.out.println("班级中" + personCount + "个人的总成绩为：" + score_sum);
        System.out.println("班级中" + personCount + "个人的平均成绩为：" + score_sum / personCount);

    }
}
